<template><div><p>本文档最新版为 <a href="https://learnku.com/docs/laravel/10.x" target="_blank" rel="noopener noreferrer">10.x</a>，旧版本可能放弃维护，推荐阅读最新版！</p>
<h2 id="laravel-的开发环境-valet" tabindex="-1"><a class="header-anchor" href="#laravel-的开发环境-valet"><span>Laravel 的开发环境 Valet</span></a></h2>
<ul>
<li><a href="#introduction">简介</a>
<ul>
<li><a href="#valet-or-homestead">Valet 还是 Homestead ？</a></li>
</ul>
</li>
<li><a href="#installation">安装</a>
<ul>
<li><a href="#upgrading">升级</a></li>
</ul>
</li>
<li><a href="#serving-sites">服务站点</a>
<ul>
<li><a href="#the-park-command">Park 命令</a></li>
<li><a href="#the-link-command">Link 命令</a></li>
<li><a href="#securing-sites">使用 TLS 构建安全站点</a></li>
</ul>
</li>
<li><a href="#sharing-sites">分享站点</a></li>
<li><a href="#custom-valet-drivers">自定义 Valet 驱动</a>
<ul>
<li><a href="#local-drivers">本地驱动</a></li>
</ul>
</li>
<li><a href="#other-valet-commands">其他 Valet 命令</a></li>
</ul>
<h2 id="简介" tabindex="-1"><a class="header-anchor" href="#简介"><span>简介</span></a></h2>
<p>Valet 是 Mac 极简主义者的 Laravel 开发环境。没有 Vagrant，没有 <code v-pre>/etc/hosts</code> 文件。甚至可以使用本地隧道公开分享你的站点。 <em>Yeah, we like it too.</em></p>
<p>Laravel Valet 为你的 Mac 设置了启动后始终在后台运行 Nginx。然后，Valet 使用 <a href="https://en.wikipedia.org/wiki/Dnsmasq" target="_blank" rel="noopener noreferrer">DnsMasq</a> 将所有指向安装在本地计算机的站点的请求代理到 <code v-pre>*.test</code> 域上。</p>
<p>换句话说，一个速度极快的 Laravel 开发环境只占用 7MB 内存。Valet 并不是想要完全替换 Vagrant 或 Homestead，只是提供另外一种使用起来更加灵活、方便、以及内存的占用更小的选择。</p>
<p>Valet 支持但不局限于以下内容：</p>
<p>However, you may extend Valet with your own <a href="#custom-valet-drivers">custom drivers</a>.</p>
<p>你可以使用 <a href="#custom-valet-drivers">自定义驱动</a> 来扩展 Valet。</p>
<h3 id="valet-还是-homestead" tabindex="-1"><a class="header-anchor" href="#valet-还是-homestead"><span>Valet 还是 Homestead？</span></a></h3>
<p>Laravel 还提供了另一种本地开发环境 <a href="https://learnku.com/docs/laravel/5.5/homestead" target="_blank" rel="noopener noreferrer">Homestead</a>。Homestead 和 Valet 的不同之处在于目标受众和对本地开发的方式。Homestead 提供了一个完整的、具有自动化的 Nginx 配置的 Ubuntu 虚拟机。如果你想要完全虚拟化的 Linux 开发环境或 Windows／Linux，Homestead 是一个不错的选择。</p>
<p>Valet 仅支持 Mac，并要求你将 PHP 和数据库服务器直接安装到本地机器上。这可以很容易地通过使用 Homebrew 命令来实现，像 <code v-pre>brew install php71</code> 和 <code v-pre>brew install mysql</code>。Valet 提供了一个极快的、资源消耗最少本地开发环境，非常适合只需要 PHP／MySQL 并且不需要虚拟开发环境的开发人员。</p>
<p>Valet 和 Homestead 都是配置 Laravel 开发环境的绝佳选择。选择哪一个仅仅只是取决于个人喜好和团队的需求。</p>
<h2 id="安装" tabindex="-1"><a class="header-anchor" href="#安装"><span>安装</span></a></h2>
<p><strong>Valet 需要 macOS 和 <a href="http://brew.sh/" target="_blank" rel="noopener noreferrer">Homebrew</a>。在安装之前，要确保没有其他程序（如 Apache 或 Nginx ）占用了本地机器的端口 80。</strong></p>
<ul>
<li>
<p>使用 <code v-pre>brew update</code> 将 Homebrew 安装或更新到最新版本。</p>
</li>
<li>
<p>通过 Homebrew 使用 <code v-pre>brew install homebrew/php/php71</code> 命令安装 PHP 7.1 。</p>
</li>
<li>
<p>通过 Composer 使用 <code v-pre>composer global require laravel/valet</code> 安装 Valet。确保 <code v-pre>~/.composer/vendor/bin</code> 目录位于系统的「PATH」中。</p>
</li>
<li>
<p>运行 <code v-pre>valet install</code> 命令来配置和安装 Valet 和 DnsMasq，并注册 Valet 后台随机启动。</p>
</li>
</ul>
<p>安装完 Valet，使用 <code v-pre>ping foobar.test</code> 命令在终端上的 ping 任何一个 <code v-pre>*.test</code> 的域名。如果 Valet 安装正确，可以在终端上看到来自 <code v-pre>127.0.0.1</code> 的响应。</p>
<p>每次机器启动时，Valet 会自动启动其进程。所以只要完成了 Valet 的初始化，就无需再次运行 <code v-pre>valet start</code> 或 <code v-pre>valet install</code>。</p>
<h4 id="使用其它域名" tabindex="-1"><a class="header-anchor" href="#使用其它域名"><span>使用其它域名</span></a></h4>
<p>默认情况下，Valet 使用 <code v-pre>.test</code> 顶级域名为你的项目提供服务。如果你想使用其他域名，可以使用 <code v-pre>valet domain tld-name</code> 命令。</p>
<p>例如，如果你要使用 <code v-pre>.app</code> 而不是 <code v-pre>.test</code>，就运行 <code v-pre>valet domain app</code>，Valet 会自动将站点域名改为 <code v-pre>*.app</code>。</p>
<h4 id="数据库" tabindex="-1"><a class="header-anchor" href="#数据库"><span>数据库</span></a></h4>
<p>如果你要用数据库，在终端运行 <code v-pre>brew install mysql</code> 安装 MySQL。安装完后，你可以使用 <code v-pre>brew services start mysql</code> 命令启动它。然后，你可以使用 <code v-pre>root</code> 作为用户名和空字符串作为密码连接到 <code v-pre>127.0.0.1</code> 的数据库。</p>
<h3 id="升级" tabindex="-1"><a class="header-anchor" href="#升级"><span>升级</span></a></h3>
<p>你可以在使用终端使用 <code v-pre>composer global update</code> 命令更新 Valet。升级后，如果需要，最好再运行一次 <code v-pre>valet install</code>，以便 Valet 可以对配置文件进行升级。</p>
<h4 id="升级到-valet-2-0" tabindex="-1"><a class="header-anchor" href="#升级到-valet-2-0"><span>升级到 Valet 2.0</span></a></h4>
<p>Valet 2.0 将 Valet 底层的 Web 服务器从 Caddy 转移到 Nginx。升级到此版本之前，你应该运行以下命令停止并卸载现有的 Caddy 进程：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">valet stop</span>
<span class="line">valet uninstall</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>接下来，就根据你如何采用的安装方式来升级 Valet （通常是通过 Git 或 Composer ）。如果是通过 Composer 安装了 Valet，则应使用以下命令更新到最新的主要版本：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">composer <span class="token keyword">global</span> <span class="token keyword">require</span> laravel<span class="token operator">/</span>valet</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>记住，只要下载了 Valet 的源码，就要运行 <code v-pre>install</code> 命令：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">valet install</span>
<span class="line">valet restart</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div><p>因为升级后，可能需要重新设置或重新链接你的站点。</p>
<h2 id="服务站点" tabindex="-1"><a class="header-anchor" href="#服务站点"><span>服务站点</span></a></h2>
<p>安装了 Valet 之后，你就可以开始设置站点。Valet 提供两个命令来为 Laravel 的站点提供服务：<code v-pre>park</code> 和 <code v-pre>link</code>。</p>
<p><strong><code v-pre>park</code> 命令</strong></p>
<ul>
<li>
<p>运行 <code v-pre>mkdir ~/Sites</code> 命令在 Mac 上创建一个新的目录。接下来，运行 <code v-pre>cd ~/Sites</code> 和 <code v-pre>valet park</code> 将当前的工作目录作为 Valet 搜索站点的路径。</p>
</li>
<li>
<p>接下来，在这个目录中创建一个新的 Laravel 站点：<code v-pre>laravel new blog</code>。</p>
</li>
<li>
<p>在浏览器中打开 <code v-pre>http://blog.test</code>。</p>
</li>
</ul>
<p>**就这么多。**现在，你在 「parked」的目录中创建的任何 Laravel 项目将自动使用 <code v-pre>http://folder-name.test</code> 这种方式访问。</p>
<p><strong><code v-pre>link</code> 命令</strong></p>
<p>如果要在目录中提供单个站点而不是整个目录，就使用 <code v-pre>link</code> 命令。</p>
<ul>
<li>要使用该命令，先切换到你的某个项目并运行 <code v-pre>valet link app-name</code>。Valet 会在 <code v-pre>~/.valet/Sites</code> 中创建一个符号链接指向当前的目录。</li>
<li>运行 <code v-pre>link</code> 命令后，你可以在浏览器通过 <code v-pre>http://app-name.test</code> 访问站点。</li>
</ul>
<p>运行 <code v-pre>valet links</code> 命令可以查看所有目录链接的列表。你还可以使用 <code v-pre>valet unlink app-name</code> 来删除符号链接。</p>
<blockquote>
<p>{tip} 你可以使用 <code v-pre>valet link</code> 将多个（子）域指向同一个应用。要添加子域名或其它域名到应用，可以在应用目录下运行 <code v-pre>valet link subdomain.app-name</code>。</p>
</blockquote>
<p><strong>使用 TLS 构建安全站点</strong></p>
<p>默认情况下，Valet 使用 HTTP 协议提供站点。但是，如果你想使用 HTTP/2 提供加密的 TLS 站点，使用 <code v-pre>secure</code> 命令。例如，如果你的站点域名是 <code v-pre>laravel.test</code>，可以这样：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">valet secure laravel</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><p>要还原为 HTTP，使用 <code v-pre>unsecure</code> 命令。像 <code v-pre>secure</code> 命令一样，此命令接受你要取消安全加密的站点名称：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line">valet unsecure laravel</span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div></div></div><h2 id="分享站点" tabindex="-1"><a class="header-anchor" href="#分享站点"><span>分享站点</span></a></h2>
<p>Valet 甚至包括与世界分享你的本地网站的命令。一旦安装了 Valet，就不需要额外的软件安装。</p>
<p>要共享站点，先在终端切换到站点目录，然后运行 <code v-pre>valet share</code> 命令。将可公开访问的网址插入剪贴板，然后直接粘贴到浏览器中访问。就这么简单～</p>
<p>要停止分享你的网站，按 <code v-pre>Control + C</code> 取消分享。</p>
<blockquote>
<p>{note} <code v-pre>valet share</code> 目前不支持使用 <code v-pre>valet secure</code> 命令保护共享的站点。</p>
</blockquote>
<h2 id="自定义-valet-驱动" tabindex="-1"><a class="header-anchor" href="#自定义-valet-驱动"><span>自定义 Valet 驱动</span></a></h2>
<p>你可以编写自己的 Valet 「驱动」来提供运行在另一个不是由 Valet 支持的框架或 CMS 上的 PHP 应用程序。安装 Valet 时，会创建一个包含 <code v-pre>SampleValetDriver.php</code> 文件 <code v-pre>~/.valet/Drivers</code> 目录。这个文件包含实现驱动程序的例子，演示了如何编写自定义驱动程序。编写驱动程序只需要实现三种方法：<code v-pre>serves</code>、 <code v-pre>isStaticFile</code> 和 <code v-pre>frontControllerPath</code>。</p>
<p>这三种方法都会收到 <code v-pre>$sitePath</code>、<code v-pre>$siteName</code> 和 <code v-pre>$uri</code> 值作为参数。<code v-pre>$sitePath</code> 是计算机上提供的站点的完整路径，例如 <code v-pre>/Users/Lisa/Sites/my-project</code>。<code v-pre>$siteName</code> 是 「主机」 / 「站点名」 的域名部分，如 <code v-pre>my-project</code>。 <code v-pre>$uri</code> 则是输入的请求地址，如 <code v-pre>/foo/bar</code>。</p>
<p>完成自定义 Valet 驱动后，使用 <code v-pre>FrameworkValetDriver.php</code> 这样的命名将其放在 <code v-pre>~/.valet/Drivers</code> 目录中。例如，如果你正在为 WordPress 编写自定义 Valet 驱动程序，那你的文件名应该是 <code v-pre>WordPressValetDriver.php</code>。</p>
<p>接下来看看自定义 Valet 驱动应该实现的每种方法的实现示例。</p>
<h4 id="serves-方法" tabindex="-1"><a class="header-anchor" href="#serves-方法"><span><code v-pre>serves</code> 方法</span></a></h4>
<p>如果你的驱动程序应该处理传入的请求，那么 <code v-pre>serves</code> 方法应该返回 <code v-pre>true</code>。否则，该方法应返回 <code v-pre>false</code>。因此，在此方法中，你需要确定给定的 <code v-pre>$sitePath</code> 是否包含你要提供的类型的项目。</p>
<p>例如，假设我们正在编写一个 <code v-pre>WordPressValetDriver</code>。<code v-pre>serve</code> 方法可能如下所示：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * 确定驱动程序是否提供请求。</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$sitePath</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$siteName</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$uri</span></span>
<span class="line"> * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">bool</span></span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">serves</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token punctuation">,</span> <span class="token variable">$siteName</span><span class="token punctuation">,</span> <span class="token variable">$uri</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token function">is_dir</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token operator">.</span><span class="token string single-quoted-string">'/wp-admin'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="isstaticfile-方法" tabindex="-1"><a class="header-anchor" href="#isstaticfile-方法"><span><code v-pre>isStaticFile</code> 方法</span></a></h4>
<p><code v-pre>isStaticFile</code> 应该确定传入的请求是否是一个「静态」的文件，如图像或样式表。如果文件是静态的，该方法应该将完整的路径返回到磁盘上的静态文件。如果传入的请求不是静态文件，则该方法应返回 <code v-pre>false</code>：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * 确定传入请求是否为静态文件。</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$sitePath</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$siteName</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$uri</span></span>
<span class="line"> * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">string</span><span class="token punctuation">|</span><span class="token keyword">false</span></span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">isStaticFile</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token punctuation">,</span> <span class="token variable">$siteName</span><span class="token punctuation">,</span> <span class="token variable">$uri</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token function">file_exists</span><span class="token punctuation">(</span><span class="token variable">$staticFilePath</span> <span class="token operator">=</span> <span class="token variable">$sitePath</span><span class="token operator">.</span><span class="token string single-quoted-string">'/public/'</span><span class="token operator">.</span><span class="token variable">$uri</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token variable">$staticFilePath</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token keyword">return</span> <span class="token constant boolean">false</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>{note} 只有当传入请求的 <code v-pre>serves</code> 方法返回 <code v-pre>true</code> 并且请求的 URI 不是 <code v-pre>/</code> 时，才会调用 <code v-pre>isStaticFile</code> 方法。</p>
</blockquote>
<h4 id="frontcontrollerpath-方法" tabindex="-1"><a class="header-anchor" href="#frontcontrollerpath-方法"><span><code v-pre>frontControllerPath</code> 方法</span></a></h4>
<p><code v-pre>frontControllerPath</code> 方法应该返回完整的路径到你应用的「前端控制器」，这通常是你的「index.php」文件或其他同等文件：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token doc-comment comment">/**</span>
<span class="line"> * 获取完全解析的路径到应用程序的前端控制器。</span>
<span class="line"> *</span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$sitePath</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$siteName</span></span>
<span class="line"> * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$uri</span></span>
<span class="line"> * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">string</span></span></span>
<span class="line"> */</span></span>
<span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">frontControllerPath</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token punctuation">,</span> <span class="token variable">$siteName</span><span class="token punctuation">,</span> <span class="token variable">$uri</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">return</span> <span class="token variable">$sitePath</span><span class="token operator">.</span><span class="token string single-quoted-string">'/public/index.php'</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="本地驱动" tabindex="-1"><a class="header-anchor" href="#本地驱动"><span>本地驱动</span></a></h3>
<p>如果要为单个应用定义一个自定义 Valet 驱动程序，请在应用程序的根目录中创建一个 <code v-pre>LocalValetDriver.php</code>。你的自定义驱动程序可以继承基础 <code v-pre>ValetDriver</code> 类或继承现有应用的特定驱动程序，如 <code v-pre>LaravelValetDriver</code>：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">LocalValetDriver</span> <span class="token keyword">extends</span> <span class="token class-name">LaravelValetDriver</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 确定驱动程序是否提供请求。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$sitePath</span></span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$siteName</span></span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$uri</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">bool</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">serves</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token punctuation">,</span> <span class="token variable">$siteName</span><span class="token punctuation">,</span> <span class="token variable">$uri</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token constant boolean">true</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line">    <span class="token doc-comment comment">/**</span>
<span class="line">     * 获取完全解析的路径到应用程序的前端控制器。</span>
<span class="line">     *</span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$sitePath</span></span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$siteName</span></span>
<span class="line">     * <span class="token keyword">@param</span>  <span class="token class-name"><span class="token keyword">string</span></span>  <span class="token parameter">$uri</span></span>
<span class="line">     * <span class="token keyword">@return</span> <span class="token class-name"><span class="token keyword">string</span></span></span>
<span class="line">     */</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">frontControllerPath</span><span class="token punctuation">(</span><span class="token variable">$sitePath</span><span class="token punctuation">,</span> <span class="token variable">$siteName</span><span class="token punctuation">,</span> <span class="token variable">$uri</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token variable">$sitePath</span><span class="token operator">.</span><span class="token string single-quoted-string">'/public_html/index.php'</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="其它-valet-命令" tabindex="-1"><a class="header-anchor" href="#其它-valet-命令"><span>其它 Valet 命令</span></a></h2>
<table>
<thead>
<tr>
<th>命令</th>
<th>注释</th>
</tr>
</thead>
<tbody>
<tr>
<td><code v-pre>valet forget</code></td>
<td>在被「parked」的目录中运行这个命令，能够将这个命令从「parked」目录列表中删除。</td>
</tr>
<tr>
<td><code v-pre>valet paths</code></td>
<td>查看所有「parked」过的路径。</td>
</tr>
<tr>
<td><code v-pre>valet restart</code></td>
<td>重启 Valet</td>
</tr>
<tr>
<td><code v-pre>valet start</code></td>
<td>启动 Valet</td>
</tr>
<tr>
<td><code v-pre>valet stop</code></td>
<td>停止 Valet</td>
</tr>
<tr>
<td><code v-pre>valet uninstall</code></td>
<td>卸载 Valet</td>
</tr>
</tbody>
</table>
<h2 id="译者署名" tabindex="-1"><a class="header-anchor" href="#译者署名"><span>译者署名</span></a></h2>
<table>
<thead>
<tr>
<th>用户名</th>
<th>头像</th>
<th>职能</th>
<th>签名</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://learnku.com/users/5350" target="_blank" rel="noopener noreferrer">@JokerLinly</a></td>
<td><img src="https://cdn.learnku.com/uploads/avatars/5350_1481857380.jpg" alt="5350_1481857380.jpg"></td>
<td>翻译</td>
<td>Stay Hungry. Stay Foolish.</td>
</tr>
</tbody>
</table>
<hr>
<blockquote>
<p>{note} 欢迎任何形式的转载，但请务必注明出处，尊重他人劳动共创开源社区。</p>
<p>转载请注明：本文档由 Laravel China 社区 <a href="https://laravel-china.org/" target="_blank" rel="noopener noreferrer">laravel-china.org</a> 组织翻译，详见 <a href="https://learnku.com/laravel/t/5756/laravel-55-document-translation-call-come-and-join-the-translation" target="_blank" rel="noopener noreferrer">翻译召集帖</a>。</p>
<p>文档永久地址： <a href="https://learnku.com/docs/laravel" target="_blank" rel="noopener noreferrer">《Laravel 中文文档》</a></p>
</blockquote>
</div></template>


